﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
 }
<div class="container-div">
    <div class="row">
        <div id="searchDiv" class="col-sm-12 search-collapse">
            <div class="select-list">
                <ul>
                    <li>
                        MyName：<input id="myName" col="MyName" type="text" />
                    </li>
                    <li>
                        <a id="btnSearch" class="btn btn-primary btn-sm" onclick="searchGrid()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="btn-group-sm hidden-xs" id="toolbar">
            <a id="btnAdd" class="btn btn-success" onclick="showSaveForm(true)"><i class="fa fa-plus"></i> 新增</a>
            <a id="btnEdit" class="btn btn-primary disabled" onclick="showSaveForm(false)"><i class="fa fa-edit"></i> 修改</a>
            <a id="btnDelete" class="btn btn-danger disabled" onclick="deleteForm()"><i class="fa fa-remove"></i> 删除</a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="gridTable" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>

<script type="text/javascript">
    $(function () {
        initGrid();
    });

    function initGrid() {
        var queryUrl = '@Url.Content("~/OrganizationManage/My/GetPageListJson")';
        $('#gridTable').ysTable({
            url: queryUrl,
            columns: [
                { checkbox: true, visible: true },
                { field: 'Id', title: 'Id', visible: false },
                
                { field: 'MyTitle', title: '网站名称' },
                { field: 'MyName', title: '网站负责人' },
                { field: 'MyPhont', title: '公司电话' },
                { field: 'MyAddress', title: '公司地址' },
                { field: 'MyYuming', title: '网站域名' },
                { field: 'MyBeian', title: '备案号' },
                { field: 'MyEmail', title: 'MyEmail' },
                { field: 'MyUsers', title: '用户数' },
                { field: 'MyTel', title: '400电话' },
                //{ field: 'MyGuanjianzi', title: 'MyGuanjianzi' },
                //{ field: 'MyMiaoshu', title: 'MyMiaoshu' },                
                //{ field: 'MyBanquan', title: 'MyBanquan' },
                //{ field: 'MyJishu', title: 'MyJishu' },
                //{ field: 'MyFax', title: 'MyFax' },
                //{ field: 'MyYoubian', title: 'MyYoubian' },
                //{ field: 'MyLogo', title: 'MyLogo' },
                //{ field: 'MyImage', title: 'MyImage' },
                //{ field: 'MyFangwen', title: 'MyFangwen' },
                //{ field: 'MyFuwushang', title: 'MyFuwushang' },                
                //{ field: 'MyWangdian', title: 'MyWangdian' },
                //{ field: 'MyWangdiancontent', title: 'MyWangdiancontent' },               
                //{ field: 'MyContent', title: 'MyContent' },
                //{ field: 'MyRemarks', title: 'MyRemarks' },
                //{ field: 'MyImages1', title: 'MyImages1' },
                //{ field: 'MyImages2', title: 'MyImages2' },
                //{ field: 'MyImages3', title: 'MyImages3' },
                //{ field: 'MyT1', title: 'MyT1' },
                //{ field: 'MyT2', title: 'MyT2' },
                //{ field: 'MyT3', title: 'MyT3' },
                //{ field: 'MyT4', title: 'MyT4' },
                //{ field: 'MyT5', title: 'MyT5' },
                //{ field: 'MyT6', title: 'MyT6' },
                //{ field: 'MyErweima', title: 'MyErweima' },
                //{ field: 'MyXiaochengxu', title: 'MyXiaochengxu' },
                //{ field: 'MyGzh', title: 'MyGzh' },
                //{ field: 'MyUrl', title: 'MyUrl' },
                //{ field: 'MyTmall', title: 'MyTmall' },
                //{ field: 'MyBeijing', title: 'MyBeijing' },
            ],
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });
    }

    function searchGrid() {
        $('#gridTable').ysTable('search');
        resetToolbarStatus();
    }

    function showSaveForm(bAdd) {
        var id = 0;
        if (!bAdd) {
            var selectedRow = $('#gridTable').bootstrapTable('getSelections');
            if (!ys.checkRowEdit(selectedRow)) {
                return;
            }
            else {
                id = selectedRow[0].Id;
            }
        }
        ys.openDialog({
            title: id > 0 ? '编辑' : '添加',
            content: '@Url.Content("~/OrganizationManage/My/MyForm")' + '?id=' + id,
            width: '768px',
            height: '550px',
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.saveForm(index);
            }
        });
    }

    function deleteForm() {
        var selectedRow = $('#gridTable').bootstrapTable('getSelections');
        if (ys.checkRowDelete(selectedRow)) {
            ys.confirm('确认要删除选中的' + selectedRow.length + '条数据吗？', function () {
                var ids = ys.getIds(selectedRow);
                ys.ajax({
                    url: '@Url.Content("~/OrganizationManage/My/DeleteFormJson")' + '?ids=' + ids,
                    type: 'post',
                    success: function (obj) {
                        if (obj.Tag == 1) {
                            ys.msgSuccess(obj.Message);
                            searchGrid();
                        }
                        else {
                            ys.msgError(obj.Message);
                        }
                    }
                });
            });
        }
    }
</script>
